/*
 * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * <p>
 * https://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.seal.commons.utils.template;


import java.io.File;
import java.io.OutputStream;
import java.io.Writer;
import java.util.Map;

/**
 * 模板接口
 *
 * @author braveblackc
 * @since 2022-10-17
 */
public interface TemplateEngine{

    /**
     * 将模板与绑定参数融合后输出到Writer
     *
     * @param name 模板名称
     * @param bindingMap 绑定的参数，此Map中的参数会替换模板中的变量
     * @param writer 输出
     */
    void render(String name, Map<?, ?> bindingMap, Writer writer);

    /**
     * 将模板与绑定参数融合后输出到流
     *
     * @param name 模板名称
     * @param bindingMap 绑定的参数，此Map中的参数会替换模板中的变量
     * @param out 输出
     */
    void render(String name, Map<?, ?> bindingMap, OutputStream out);

    /**
     * 写出到文件
     *
     * @param name 模板名称
     * @param bindingMap 绑定的参数，此Map中的参数会替换模板中的变量
     * @param file 输出到的文件
     */
    void render(String name, Map<?, ?> bindingMap, File file);

    /**
     * 将模板与绑定参数融合后返回为字符串
     *
     * @param name 模板名称
     * @param bindingMap 绑定的参数，此Map中的参数会替换模板中的变量
     * @return 融合后的内容
     */
    String render(String name, Map<?, ?> bindingMap);

}
